import { SET_HOME_CATEGORIES } from '../types'
import HomeApi from 'api/home'

const state = {
  categories: []
}

const actions = {
  getCategories ({commit}) {
    HomeApi.getCategories().then(res => {
      commit(SET_HOME_CATEGORIES, res.data)
    })
  }
}

const getters = {
  categories: state => state.categories
}

const mutations = {
  [SET_HOME_CATEGORIES] (state, categories) {
    state.categories = categories
  }
}

export default {
  state,
  actions,
  getters,
  mutations
}
